local yingshou = fk.CreateSkill{
    name = "wk_heg__yingshou",
}

Fk:loadTranslationTable{
    ["wk_heg__yingshou"] = "营守",
    [":wk_heg__yingshou"] = "结束阶段，你可令一名与你势力相同的角色摸两张牌，若如此做，当其于下个出牌阶段内造成伤害后，其弃置一张牌。",

    ["#wk_heg__yingshou-choose"] = "营守：选择一名与你势力相同的角色",
    ["@@wk_heg__yingshou"] = "营守",

    ["$wk_heg__yingshou1"] = "由缓至急，循循而进。",
    ["$wk_heg__yingshou2"] = "事须缓图，欲速不达也。",
}

local H = require "packages/ol_hegemony/util"

yingshou:addEffect(fk.EventPhaseStart,{
    anim_type = "drawcard",
    can_trigger = function (self, event, target, player, data)
        return target == player and player.phase == Player.Finish and player:hasSkill(yingshou.name)
      end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local targets = table.filter(room.alive_players, function(p) return H.compareKingdomWith(player, p) end)
        local tos = room:askToChoosePlayers(player,{
            targets = targets,
            min_num = 1,
            max_num = 1,
            prompt = "#wk_heg__yingshou-choose",
            skill_name = yingshou.name
        })
        if #tos > 0 then
          local to = tos[1]
          to:drawCards(2, yingshou.name)
          room:setPlayerMark(to, "@@wk_heg__yingshou", 1)
       end
    end,
})

yingshou:addEffect(fk.Damage,{
    anim_type = "special",
    is_delay_effect = true,
    can_trigger = function (self, event, target, player, data)
       return data.from:getMark("@@wk_heg__yingshou") > 0 and not data.from:isNude() and data.from.phase == Player.Play and player:hasSkill(yingshou.name)
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        player.room:askToDiscard(data.from,{
            min_num = 1,
            max_num = 1,
            include_equip = true,
            skill_name = yingshou.name,
            cancelable = false,
        })
    end,
})

yingshou:addEffect(fk.EventPhaseEnd,{
    can_refresh = function (self, event, target, player, data)
       return target:getMark("@@wk_heg__yingshou") > 0 and target.phase == Player.Play
    end,
    on_refresh = function (self, event, target, player, data)
       player.room:setPlayerMark(target, "@@wk_heg__yingshou", 0)
    end,
})

return yingshou